from datetime import datetime
from sqlalchemy import Column, Integer, Date, DECIMAL, CHAR, String, DateTime, ForeignKey, SmallInteger
from config.database import Base


class AttendanceInfo(Base):
    """
    考勤表
    """
    __tablename__ = 'attendance'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='ID')
    employee_id = Column(Integer, ForeignKey('employee_info.id'), nullable=False, comment='员工ID')
    attendance_date = Column(Date, nullable=True, comment='考勤日期')
    status = Column(SmallInteger, nullable=True, comment='状态: 0=出勤, 1=休假, 2=事假, 3=矿工')
    hours_worked = Column(DECIMAL(3, 1), nullable=True, default=0.0, comment='工作小时数')
    del_flag = Column(CHAR(1), nullable=True, default='0', comment='删除标志（0代表存在 2代表删除）')
    create_by = Column(String(64), nullable=True, comment='创建者')
    create_time = Column(DateTime, nullable=True, default=datetime.now(), comment='创建时间')
    update_by = Column(String(64), nullable=True, comment='更新者')
    update_time = Column(DateTime, nullable=True, default=datetime.now(), onupdate=datetime.now, comment='更新时间') 